/**
 * 
 */
package kr.co.magic;

import kr.co.magic.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

/**
 * @author johnkim
 *
 */
public class BarcodeScannerView extends Activity {
	public static final String TAG = BarcodeScannerView.class.getSimpleName();

	/* (non-Javadoc)
	 * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
	 */
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, intent);
		
		if(requestCode == 0) {
              if(resultCode == RESULT_OK) {
                     DongyangView.barCode = intent.getStringExtra("SCAN_RESULT");
              } else if(resultCode == RESULT_CANCELED) {
              	Toast.makeText(BarcodeScannerView.this, "바코드 인식에 실패했습니다." + "\n" + "다시 시도해 주세요.", Toast.LENGTH_SHORT).show();
              }
        }
	}

	/* (non-Javadoc)
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.barcodescanner);
		
		Intent intent = new Intent("com.google.zxing.client.android.SCAN");
        intent.setPackage("com.google.zxing.client.android");
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

        startActivityForResult(intent, 0);
	}
	
	

}
